package cn.limc.ohoscharts.demo.slice;

import cn.limc.ohoscharts.demo.ResourceTable;
import cn.limc.ohoscharts.entity.TitleValueColorEntity;
import cn.limc.ohoscharts.view.PieChart;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;

import java.util.ArrayList;
import java.util.List;

public class PieChartAbility extends AbilitySlice {

  PieChart piechart;

  @Override
  public void onStart(Intent intent) {
    super.onStart(intent);
    super.setUIContent(ResourceTable.Layout_ability_pie_chart);
    initPieChart();
  }

  private void initPieChart() {
    this.piechart = (PieChart) findComponentById(ResourceTable.Id_piechart);
    final List<TitleValueColorEntity> data3 = new ArrayList<TitleValueColorEntity>();
    data3.add(new TitleValueColorEntity("Alpha", 2,
        0xFFFF0000));
    data3.add(new TitleValueColorEntity("Bravo", 3,
        0xFFFF8D00));
    data3.add(new TitleValueColorEntity("Charlie", 6,
        0xFFFFFF00));
    data3.add(new TitleValueColorEntity("Delta", 2,
        0xFF96FF00));
    data3.add(new TitleValueColorEntity("Echo", 2,
        0xFF00FF00));
    piechart.setData(data3);
  }
}
